<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create GMP number</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.gmp-import.html">« gmp_import</a></li>
      <li style="float: right;"><a href="function.gmp-intval.html">gmp_intval »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.gmp.html">GMP 函数</a></li>
    <li>Create GMP number</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.gmp-init" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmp_init</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gmp_init</span> &mdash; <span class="dc-title">Create GMP number</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gmp-init-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gmp_init</strong></span>(<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$num</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$base</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="class.gmp.html" class="type GMP">GMP</a></span></div>

  <p class="para rdfs-comment">
   Creates a GMP number from an integer or string. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gmp-init-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">num</code></dt>

     <dd>

      <p class="para">
       An integer or a string. The string representation can be decimal, 
       hexadecimal or octal.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">base</code></dt>

     <dd>

      <p class="para">
       The base.
      </p>
      <p class="para">
       The base may vary from 2 to 62. If base is 0 (default value), the
       actual base is determined from the leading characters: if the first
       two characters are <code class="literal">0x</code> or <code class="literal">0X</code>,
       hexadecimal is assumed, if the first two characters are <code class="literal">0b</code> or <code class="literal">0B</code>,
       binary is assumed, otherwise if the first character is <code class="literal">0</code>,
       octal is assumed, otherwise decimal is assumed.
       For bases up to 36, case is ignored; upper-case and lower-case letters have the same value.
       For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmp-init-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="classname"><a href="class.gmp.html" class="classname">GMP</a></span> 对象。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gmp-init-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3050">
    <p><strong>示例 #1 Creating GMP number</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_init</span><span style="color: #007700">(</span><span style="color: #0000BB">123456</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"0xFFFFDEBACDFEDF7200"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.gmp-init-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    It is not necessary to call this function in order to use integers or
    strings in place of GMP numbers in GMP functions (such as with
    <span class="function"><a href="function.gmp-add.html" class="function">gmp_add()</a></span>). Function arguments are automatically
    converted to GMP numbers, if such conversion is possible and needed, using
    the same rules as <span class="function"><strong>gmp_init()</strong></span>.
   </p>
  </p></blockquote>
 </div>

 
</div></div></div></body></html>